<template>
	<view class="page">
		<u-loading-page loading-text="加载中" :loading="loading"></u-loading-page>
		<view class="inp">
			<u-input v-model="value" fontSize="12" border="surround" placeholder="请输入">
				<template slot="prefix">
					<u-icon name="search" color="#9e9e9e" size="24"></u-icon>
				</template>
			</u-input>
			<view style="width: 120rpx; text-align: center;">搜索</view>
		</view>
		
		<dropdown-list :show="shows" :top="94" :height="400">
			<template v-slot:selectionbox>
				<view class="top">
					<view class="top-name" @click="dropDownList(-1)">
						<view>{{orders}}</view>
						<u-icon name="arrow-down"></u-icon>
						<u-line length="16" direction="col" margin="0rpx 20rpx"></u-line>
					</view>

				</view>
			</template>
			<template v-slot:dropdownbox>
				<view class="tui-selected-list">
					<scroll-view scroll-y class="tui-dropdown-scroll">
						<block v-for="(item,index) in dropdownlistData" :key="index">
							<!-- <tui-list-cell padding="0"
								:unlined="dropdownlistData.length-1==index"> -->
								<view class="tui-cell-class" @click="dropDownList(item)">
									<text class="tui-ml-20">{{item.name}}</text>
								</view>
							<!-- </tui-list-cell> -->
						</block>
					</scroll-view>
				</view>
			</template>
		</dropdown-list>
		
		<view style="font-size: 24rpx; margin: 20rpx;">共<text style="color:#257CFF">{{lists.length}}</text>条数据</view>

		<view class="content" v-for="(item,index) in lists" :key="index">
			<view class="order-top">
				<view class="le">
					订单编号：{{item.id}}
				</view>
				<view class="re" v-if="item.status==80">已完成</view>
				<view class="re" v-else-if="item.status==0">待支付</view>
			<!-- 	<view class="re" v-else-if="item.status==10">待接单</view> -->
				<view class="re" v-else-if="item.status==20">待到店</view>
				<view class="re" v-else-if='item.status==30&&item.refundNotes!=""'>待重新诊断</view>
				<view class="re" v-else-if="item.status==30">待诊断</view>
		        <view class="re" v-else-if="item.status==40">待审核</view>
				<view class="re" v-else>施工中</view>
			</view>
			<u-line color="#ececec"></u-line>
			<view class="order">
				<image class="img" :src="item.modelsImg"></image>
				<view class="content1">
					<view class="content-name">{{item.carNumber}}</view>
					<view class="content-map">{{item.productNameStr}}</view>
					<view class="content-time">{{item.createTime}}</view>
				</view>
			</view>
			<u-line color="#ececec"></u-line>
			<view class="but">
				<view class="button" @click="$goBack(2,'/bundle/pages/repairdetails/repairdetails?id='+item.id)">查看详情
				</view>
				<view style="font-weight: 600;">订单金额：<text style="color: red;">¥:{{item.totalPrice}}</text></view>
			</view>
		</view>

		<u-action-sheet :actions="list" @select="selectClick" :show="show"></u-action-sheet>
		<u-empty v-if="lists.length==0" text="暂无数据">
		</u-empty>
	</view>
</template>

<script>
	import DropdownList from '../../../components/tui-dropdown-list/tui-dropdown-list.vue'
	import {
		apigetStoreOrderList
	} from '@/api/orders.js'
	export default {
		components: {
			DropdownList
		},
		data() {
			return {
				value:'',
				list: [{
						name: '选项一'
					},
					{
						name: '选项二'
					}
				],
				show: false,
				lists: [],
				loading:true,
				shows:false,
				orders:'订单状态',
				dropdownlistData: [
					{
						name:'全部订单',
						status:null
					},
					{
						name: "待到店",
						status: 20
					},
					{
						name: "待重新审核",
						status: 30
					},
					{
						name: "待服务",
						status: 40
					},
					{
						name: "维修/ 保养中",
						status: 50
					},
					{
						name: "已完成",
						status: 80
					},
				
				],
			}
		},
		onLoad() {
			this.selectDetailByTime()
		},
		methods: {
			dropDownList(item) {
				if (item == -1) {
					this.shows = !this.shows
					return 
					// this.tui.toast("index：" + index)
				}
				this.orders=item.name
				// this.selectDetailByTime(item.status)
				this.shows = !this.shows
			},
			selectClick(e) {
				this.show = false
			},
				selectDetailByTime() {
				let id = uni.getStorageSync("businessId")
				apigetStoreOrderList(id).then((res) => {
					this.lists = res.data.records
					this.loading=false
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.tui-drop-input-box {
		padding: 50rpx;
		box-sizing: border-box;
	}
	
	.tui-animation {
		display: inline-block;
		transform: rotate(0deg);
		transition: all 0.2s;
	}
	
	.tui-animation-show {
		transform: rotate(180deg);
	}
	
	.tui-selected-list {
		background-color: #fff;
		border-radius: 20rpx;
		overflow: hidden;
		transform: translateZ(0);
	}
	
	.tui-dropdown-scroll {
		height: 400rpx;
	}
	
	.tui-cell-class {
		display: flex;
		align-items: center;
		padding: 26rpx 30rpx !important;
	}
	
	.tui-ml-20 {
		margin-left: 20rpx;
		font-size: 24rpx
	}
	.inp {
		box-sizing: border-box;
		padding: 20rpx;
		background-color: #fff;
		@include flex(row, space-between, center) font-size: 30rpx;
	}

	.top {
		padding: 20rpx;
		height: 84rpx;
		font-size: 28rpx;
		background-color: #fff;
		text-align: center;

		@include flex(row, space-between, center) .top-name {

			display: flex;
		}
	}

	.content {
		width: 718rpx;
		height: 340rpx;
		margin: 16rpx;
		padding: 26rpx 20rpx;
		box-sizing: border-box;
		background-color: #fff;
		border-radius: 20rpx;

		.order-top {
			margin-bottom: 10rpx;
			font-weight: 600;

			@include flex(row, space-between, center) .le {

				font-size: 28rpx;
			}

			.re {
				font-size: 28rpx;
				color: #257CFF;
			}

		}

		.order {
			margin: 20rpx 10rpx;
			display: flex;

			.img {
				border-radius: 10rpx;
				width: 160rpx;
				height: 160rpx;
			}

			.content1 {
				width: 440rpx;
				margin-left: 20rpx;
				line-height: 40rpx;

				.content-name {
					font-size: 28rpx;
					font-weight: 600;
				}

				.content-time {
					font-size: 24rpx;
					color: #949494;
				}

				.content-map {
					font-size: 28rpx;
				}
			}
		}

		.store {
			font-size: 26rpx;
			margin: 8rpx 0rpx;
		}

		.order-content {
			width: 666rpx;
			font-size: 24rpx;
			color: #666666;
			margin-bottom: 6rpx;
		}

		.time {
			margin-bottom: 8rpx;
			color: #949494;
			font-size: 24rpx;
		}

		.but {
			margin-top: 16rpx;
			font-size: 28rpx;

			@include flex(row, space-between, center) .button {
				color: #257CFF;
			}
		}
	}

	::v-deep .u-transition {
		// position: absolute !important;
		top: 120rpx !important;
	}

	::v-deep .u-input {
		margin: 0rpx 40rpx 0rpx 32rpx;
		background-color: #efefef !important;

	}
</style>